package tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import java.io.IOException;

public class CustomTag1 implements Tag {
    private PageContext pageContext;
    private Tag parent;

    @Override
    public void setPageContext(PageContext pageContext) { this.pageContext = pageContext; }

    public PageContext getPageContext() { return pageContext; }

    @Override
    public void setParent(Tag tag) { this.parent = tag; }

    @Override
    public Tag getParent() { return parent; }

    @Override
    public int doStartTag() throws JspException {
        JspWriter out = pageContext.getOut();
        try {
            out.print("你好，");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return EVAL_BODY_INCLUDE;
    }

    @Override
    public int doEndTag() throws JspException {
        JspWriter out = pageContext.getOut();
        try {
            out.print("！");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return EVAL_PAGE;
    }

    @Override
    public void release() {}
}
